﻿#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<assert.h>
﻿char* my_strstr(char* dest, const char* src)
{
	assert(dest && src);
	char* ret = dest;
	char* cp = dest;
	char* s1 = 0;
	char* s2 = 0;
	while (*cp)
	{
		s1 = cp;
		s2 = src;
		while (*s1 && *s2 && *s1 == *s2)
		{
			s1++;
			s2++;
		}
		if (*s2 == '\0')
			return cp;
		cp++;
	}
	return NULL;
}


int main()
{
	char arr[] = "abbcdef";
	char str[] = "bcd";
	char* ret = my_strstr(arr, str);
	printf("%s", ret);
	return 0;
}

/*#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<assert.h>
#include<string.h>
int main() 枚举法
{
	char arr[30] = "abbcdefg";
	char str[] = "bcd";
	int len1 = strlen(arr);
	int len2 = strlen(str);
	for (int i = 0; i + len2 <= len1; i++)
	{
		int j = 0;
		for (; j < len2; j++)
		{
			if (arr[i + j] !=str[j])
				break;
		}
		if (j == len2)
		{
			printf("%s", &arr[i]);
			return 0;
		}
	}
	printf("找不到\n");
}*/
